#define   _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <assert.h>
#include <ctype.h>
#include <limits.h>
enum Status
{
	VALID,
	INVALID
}status = INVALID;
int my_atoi(const char* str)
{
	assert(str);
	int flag = 1;
	if (*str == '\0')
	{
		return 0;
	}
	while (isspace(*str))
	{
		str++;
	}
	if (*str == '+')
	{
		flag = 1;
		str++;
	}
	else if (*str == '-')
	{
		flag = -1;
		str++;
	}
	long long n = 0;
	while (*str != '\0')
	{
		if (isdigit(*str))
		{
			n = n * 10 + flag * (*str - '0');
			if (n<INT_MIN || n > INT_MAX)
			{
				n = 0;
				break;
			}
		}

		else
		{
			break;
		}
		str++;
	}	
	
	if (*str == '\0')
	{
		status = VALID;
	}
	return (int)n;
}